#! /usr/bin/env python #-*- coding: UTF8 -*- # PSP Tools """ Mapping of the PSP buttons on a PC, usefull for beta-testing z = cross a = square s = circle w = triangle e = r-trigger q = l-trigger v = start c = select up,down,left,right = arrow keys """ changelog = """ Alpha: Successfuly ported the core to the psp, no user input, no release Alpha 0.1: Added user input Fixed version.txt bug Added more tools: pixel fix and button test renamed the project public release Alpha 0.2: Added savedata backup utility Added free space utility Beta 0.1: Added more use of the log.txt file Changed the eboot title and PIC0.PNG Enhanced the pixel fixer Changed the Menu to a more intuitive one Added HBL Loader """ import os, pspos, psp2d, zipfile, glob, shutil, random, time, sys, getopt, os.path abspath = os.path.abspath(__file__) path = os.path.dirname(abspath) + "/" pspos.setclock(333) pspos.setbus(166) WHITE_COLOR = psp2d.Color(255,255,255) CLEAR_COLOR = psp2d.Color(0,0,0) RED_COLOR = psp2d.Color(255, 0, 0) GREEN_COLOR = psp2d.Color(0, 255, 0) BLUE_COLOR = psp2d.Color(0,50,255) YELLOW_COLOR = psp2d.Color(255,255,0) scr = psp2d.Screen() fnt = psp2d.Font(path+'font.png') img = psp2d.Image(480, 272) global tools_position tools_position = 0 try: log = open("log.txt", "a") except: log = open("log.txt", "w") log = open("log.txt", "a") log.write("\nprogram started\n") class unzip: # Used by HBL Loader def __init__(self, verbose = False, percent = 10): self.verbose = verbose self.percent = percent def extract(self, file, dir): #if not dir.endswith(':') and not os.path.exists(dir): # os.mkdir(dir) zf = zipfile.ZipFile(file) self._createstructure(file, dir) num_files = len(zf.namelist()) percent = self.percent divisions = 100 / percent perc = int(num_files / divisions) for i, name in enumerate(zf.namelist()): if not name.endswith('/'): outfile = open(os.path.join(dir, name), 'wb') outfile.write(zf.read(name)) outfile.flush() outfile.close() def _createstructure(self, file, dir): self._makedirs(self._listdirs(file), dir) def _makedirs(self, directories, basedir): for dir in directories: curdir = os.path.join(basedir, dir) if not os.path.exists(curdir): os.mkdir(curdir) def _listdirs(self, file): zf = zipfile.ZipFile(file) dirs = [] for name in zf.namelist(): if name.endswith('/'): dirs.append(name) dirs.sort() return dirs def scan(): # Scans and fixes missing directories if os.path.isdir("ms0:/MP_ROOT") == False: os.mkdir("ms0:/MP_ROOT") log.write("ms0:/MP_ROOT missing...fixed\n") if os.path.isdir("ms0:/MP_ROOT/100MNV01") == False: os.mkdir("ms0:/MP_ROOT/100MNV01") log.write("ms0:/MP_ROOT/100MNV01 missing...fixed\n") if os.path.isdir("ms0:/MP_ROOT/101ANV01") == False: os.mkdir("ms0:/MP_ROOT/101ANV01") log.write("ms0:/MP_ROOT/101ANV01 missing...fixed\n") if os.path.isdir("ms0:/PSP") == False: os.mkdir("ms0:/PSP") log.write("ms0:/PSP missing...fixed\n") if os.path.isdir("ms0:/PSP/GAME") == False: os.mkdir("ms0:/PSP/GAME") log.write("ms0:/PSP/GAME missing...fixed\n") if os.path.isdir("ms0:/PSP/GAME150") == False: os.mkdir("ms0:/PSP/GAME150") log.write("ms0:/PSP/GAME150 missing...fixed\n") if os.path.isdir("ms0:/PSP/SAVEDATA") == False: os.mkdir("ms0:/PSP/SAVEDATA") log.write("ms0:/PSP/SAVEDATA missing...fixed\n") if os.path.isdir("ms0:/PSP/PHOTO") == False: os.mkdir("ms0:/PSP/PHOTO") log.write("ms0:/PSP/PHOTO missing...fixed\n") if os.path.isdir("ms0:/PSP/VIDEO") == False: os.mkdir("ms0:/PSP/VIDEO") log.write("ms0:/PSP/VIDEO missing...fixed\n") if os.path.isdir("ms0:/PSP/THEME") == False: os.mkdir("ms0:/PSP/THEME") log.write("ms0:/PSP/THEME missing...fixed\n") if os.path.isdir("ms0:/PSP/COMMON") == False: os.mkdir("ms0:/PSP/COMMON") log.write("ms0:/PSP/COMMON missing...fixed\n") if os.path.isdir("ms0:/PSP/SYSTEM") == False: os.mkdir("ms0:/PSP/SYSTEM") log.write("ms0:/PSP/SYSTEM missing...fixed\n") if os.path.isdir("ms0:/PSP/RSSCH") == False: os.mkdir("ms0:/PSP/RSSCH") log.write("ms0:/PSP/RSSCH missing...fixed\n") if os.path.isdir("ms0:/PSP/RSSCH/IMPORT") == False: os.mkdir("ms0:/PSP/RSSCH/IMPORT") log.write("ms0:/PSP/RSSCH/IMPORT missing...fixed\n") if os.path.isdir("ms0:/PSP/MUSIC") == False: os.mkdir("ms0:/PSP/MUSIC") log.write("ms0:/PSP/MUSIC missing...fixed\n") if os.path.isdir("ms0:/VIDEO") == False: os.mkdir("ms0:/VIDEO") log.write("ms0:/VIDEO missing...fixed\n") if os.path.isdir("ms0:/MUSIC") == False: os.mkdir("ms0:/MUSIC") log.write("ms0:/MUSIC missing...fixed\n") if os.path.isdir("ms0:/PICTURE") == False: os.mkdir("ms0:/PICTURE") log.write("ms0:/PICTURE missing...fixed\n") if os.path.isdir("ms0:/ISO") == False: os.mkdir("ms0:/ISO") log.write("ms0:/ISO missing...fixed\n") if os.path.isdir("ms0:/ISO/VIDEO") == False: os.mkdir("ms0:/ISO/VIDEO") log.write("ms0:/ISO/VIDEO missing...fixed\n") if os.path.isdir("ms0:/SEPLUGINS") == False: os.mkdir("ms0:/SEPLUGINS") log.write("ms0:/SEPLUGINS missing...fixed\n") try: open("ms0:/SEPLUGINS/game.txt", "r").close() except: open("ms0:/SEPLUGINS/game.txt", "w").close() log.write("ms0:/SEPLUGINS/game.txt missing...fixed\n") try: open("ms0:/SEPLUGINS/pops.txt", "r").close() except: open("ms0:/SEPLUGINS/pops.txt", "w").close() log.write("ms0:/SEPLUGINS/pops.txt missing...fixed\n") try: open("ms0:/SEPLUGINS/vsh.txt", "r").close() except: open("ms0:/SEPLUGINS/vsh.txt", "w").close() log.write("ms0:/SEPLUGINS/vsh.txt missing...fixed\n") try: open("ms0:/SEPLUGINS/game150.txt", "r").close() except: open("ms0:/SEPLUGINS/game150.txt", "w").close() log.write("ms0:/SEPLUGINS/game150.txt missing...fixed\n") try: open("ms0:/SEPLUGINS/version.txt", "r").close() except: open("ms0:/SEPLUGINS/version.txt", "w").write("""release:9.90: build:6666,0,3,1,0:builder@vsh-build6 system:54865@release_610,0x09090010: vsh:p6501@release_610,v55286@release_610,20121221: target:1:WorldWide """) log.write("ms0:/SEPLUGINS/version.txt missing...fixed\n") try: open("ms0:/MEMSTICK.IND", "r").close() except: open("ms0:/MEMSTICK.IND", "w").close() log.write("ms0:/MEMSTICK.IND missing...fixed\n") done("Directories fixed") def pixel_fix(): # Stuck pixel fixer x12 = True log.write("pixel fixer started\n") while x12 == True: pad = psp2d.Controller() time.sleep(0.07) img.clear(WHITE_COLOR) scr.blit(img) scr.swap() time.sleep(0.07) img.clear(RED_COLOR) scr.blit(img) scr.swap() time.sleep(0.07) img.clear(GREEN_COLOR) scr.blit(img) scr.swap() time.sleep(0.07) img.clear(BLUE_COLOR) scr.blit(img) scr.swap() time.sleep(0.07) img.clear(YELLOW_COLOR) scr.blit(img) scr.swap() if pad.triangle: x12 = False log.write("pixel fixer ended by user\n") done("Pixel Fix cancelled, quit?") def button_test(): # Test buttons individualy and generaly x0 = True while x0 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press X""") scr.blit(img) scr.swap() if pad.cross: log.write("cross button ok\n") x0 = False x1 = True while x1 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Circle""") scr.blit(img) scr.swap() if pad.circle: log.write("circle button ok\n") x1 = False x2 = True while x2 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Square""") scr.blit(img) scr.swap() if pad.square: log.write("square button ok\n") x2 = False x3 = True while x3 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Triangle""") scr.blit(img) scr.swap() if pad.triangle: log.write("triangle button ok\n") x3 = False x4 = True while x4 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Right Trigger""") scr.blit(img) scr.swap() if pad.r: log.write("right trigger button ok\n") x4 = False x5 = True while x5 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Left Trigger""") scr.blit(img) scr.swap() if pad.l: log.write("left trigger button ok\n") x5 = False x6 = True while x6 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Start""") scr.blit(img) scr.swap() if pad.start: log.write("start button ok\n") x6 = False x7 = True while x7 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Select""") scr.blit(img) scr.swap() if pad.select: log.write("select button ok\n") x7 = False x8 = True while x8 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Left""") scr.blit(img) scr.swap() if pad.left: log.write("left button ok\n") x8 = False x9 = True while x9 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Right""") scr.blit(img) scr.swap() if pad.right: log.write("right button ok\n") x9 = False x10 = True while x10 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Up""") scr.blit(img) scr.swap() if pad.up: log.write("up button ok\n") x10 = False x11 = True while x11 == True: pad = psp2d.Controller() img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """Press Down""") scr.blit(img) scr.swap() if pad.down: log.write("down button ok\n") x11 = False wait = 10 while wait > 0: pad = psp2d.Controller() #time.sleep(0.20) img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 60, """DONT PRESS ANYTHING!!!""") scr.blit(img) scr.swap() time.sleep(1) wait -= 1 if pad.cross: wait = 0 log.write("problem with cross button\n") log.flush() info = "Detected input for cross" elif pad.circle: wait = 0 log.write("problem with circle button\n") log.flush() info = "Detected input for circle" elif pad.square: wait = 0 log.write("problem with square button\n") log.flush() info = "Detected input for square" elif pad.triangle: wait = 0 log.write("problem with triangle button\n") log.flush() info = "Detected input for triangle" elif pad.r: wait = 0 log.write("problem with R-trigger button\n") log.flush() done("Detected input for R-trigger") elif pad.l: wait = 0 log.write("problem with L-trigger button\n") log.flush() info = "Detected input for L-trigger" elif pad.start: wait = 0 log.write("problem with start button\n") log.flush() info = "Detected input for start" elif pad.select: wait = 0 log.write("problem with select button\n") log.flush() info = "Detected input for select" elif pad.up: wait = 0 log.write("problem with up button\n") log.flush() info = "Detected input for up" elif pad.left: wait = 0 log.write("problem with left button\n") log.flush() info = "Detected input for left" elif pad.right: wait = 0 log.write("problem with right button\n") log.flush() info = "Detected input for right" else: info = "Button test finished, quit?" done(info) def savedata_util(): # Backup and restore savedata img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, """Savedata Backup Utility""") fnt.drawText(img, 0, 30, """Cross --> Create backup""") fnt.drawText(img, 0, 60, """Circle --> Restore backup""") fnt.drawText(img, 0, 90, """Triangle --> Cancel""") scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.cross: x = False target_dir = "ms0:/PSP/SAVEDATA" zip = zipfile.ZipFile("save_bak.zip", "w", zipfile.ZIP_DEFLATED) rootlen = len(target_dir) + 1 for base, dirs, files in os.walk(target_dir): for file in files: fn = os.path.join(base, file) zip.write(fn, fn[rootlen:]) log.write("SAVEDATA backup created\n") done("Backup created") elif pad.circle: x = False bak = zipfile.ZipFile("save_bak.zip", "r") bak.extractall(path="ms0:/PSP/SAVEDATA/") log.write("SAVEDATA backup restored\n") done("Backup restored") elif pad.triangle: done("Exit?") def done(custom=input): # A common "done" screan that asks to exit, the question is variable img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, custom) fnt.drawText(img, 0, 30, "Start --> main menu") fnt.drawText(img, 0, 60, "Select --> exit") scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.start: x = False main() elif pad.select: log.write("program ended by user") log.close() fnt.drawText(img, 0, 90, "Exiting...") scr.blit(img) scr.swap() break def ms_clean(): # Delete some files to free space img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, """This will delete:""") fnt.drawText(img, 0, 30, """- All Videos""") fnt.drawText(img, 0, 60, """- All Music""") fnt.drawText(img, 0, 90, """- All Photos""") fnt.drawText(img, 0, 120, """- Common Folder""") fnt.drawText(img, 0, 150, """Cross --> OK""") fnt.drawText(img, 0, 180, """Circle --> Cancel""") scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.cross: x = False try: shutil.rmtree("ms0:/VIDEO", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/PSP/VIDEO", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/MUSIC", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/PSP/MUSIC", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/PICTURE", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/PSP/PHOTO", ignore_errors=True) except: print"" try: shutil.rmtree("ms0:/PSP/COMMON", ignore_errors=True) except: print"" try: os.mkdir("ms0:/PSP") except: print"" try: os.mkdir("ms0:/VIDEO") except: print"" try: os.mkdir("ms0:/PSP/VIDEO") except: print"" try: os.mkdir("ms0:/MUSIC") except: print"" try: os.mkdir("ms0:/PSP/MUSIC") except: print"" try: os.mkdir("ms0:/PICTURE") except: print"" try: os.mkdir("ms0:/PSP/PHOTO") except: print"" try: os.mkdir("ms0:/PSP/COMMON") except: print"" log.write("memory stick space freed\n") done("Space freed, quit?") if pad.circle: x = False main() def psp2vhbl(): # Convert a homebrew to VHBL format def recursive_zip(zipf, directory, folder): for item in os.listdir(directory): if os.path.isfile(os.path.join(directory, item)): zipf.write(os.path.join(directory, item), folder + os.sep + item) elif os.path.isdir(os.path.join(directory, item)): recursive_zip(zipf, os.path.join(directory, item), folder + os.sep + item) zipf.close() apps_position = 0 target_dir = "ms0:/PSP/GAME" for base, dirs, files in os.walk(target_dir, topdown=False): apps = dirs img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, apps[apps_position]) scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.cross: x = False zipf = zipfile.ZipFile("install.zip", "w", compression=zipfile.ZIP_STORED) directory = str(target_dir+"/"+apps[apps_position]) folder = apps[apps_position] recursive_zip(zipf, directory, folder) try: zipf.close() except: print "" try: os.mkdir("ms0:/psp2vhbl") except: print "" random_savedata = "UCES"+"".join(random.sample("1234567890", 6)) os.mkdir("ms0:/psp2vhbl/"+random_savedata) # patch for the psp try: os.rename(random_savedata,"install.zip") except: print"" # end patch shutil.copyfile("install.zip", "ms0:/psp2vhbl/"+random_savedata+"/install.zip") os.remove("install.zip") done("Done!") elif pad.circle: x = False done("Quit?") elif pad.down: try: apps_position = apps_position+1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, apps[apps_position]) scr.blit(img) scr.swap() except: apps_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, apps[apps_position]) scr.blit(img) scr.swap() elif pad.up: try: apps_position = apps_position-1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, apps[apps_position]) scr.blit(img) scr.swap() except: apps_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, apps[apps_position]) scr.blit(img) scr.swap() def hbl_loader(): # Install HBL for 6.20 or 6.60 def install(): try: os.remove("ms0:/h.bin") except: print "" try: shutil.rmtree("ms0:/hbl") except: print "" try: shutil.rmtree("ms0:/PSP/GAME/HBL") except: print "" if hbls[hbls_position] == "> 6.20": unzipper = unzip() unzipper.extract("hbl/620.zip", "ms0:/") done("HBL for 6.20 Installed, quit?") elif hbls[hbls_position] == "> 6.60": unzipper = unzip() unzipper.extract("hbl/660.zip", "ms0:/") done("HBL for 6.60 Installed, quit?") elif hbls[hbls_position] == "> Uninstall": done("HBL Uninstalled, quit?") hbls= [ "> 6.20", #0 "> 6.60", #1 "> Uninstall" #2 ] hbls_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, hbls[hbls_position]) scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.down: try: hbls_position = hbls_position+1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, hbls[hbls_position]) scr.blit(img) scr.swap() except: hbls_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, hbls[hbls_position]) scr.blit(img) scr.swap() elif pad.up: try: hbls_position = hbls_position-1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, hbls[hbls_position]) scr.blit(img) scr.swap() except: hbls_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, hbls[hbls_position]) scr.blit(img) scr.swap() elif pad.cross: x = False install() elif pad.circle: x = False done("Quit?") def main(): # Main Menu global tools_position def work(): if tools[tools_position] == "> Directory Fix": scan() elif tools[tools_position] == "> Button Test": button_test() elif tools[tools_position] == "> Pixel Fix": pixel_fix() elif tools[tools_position] == "> Free Space": ms_clean() elif tools[tools_position] == "> Savedata Backup": savedata_util() elif tools[tools_position] == "> HBL Loader": hbl_loader() elif tools[tools_position] == "> PSP to VHBL": psp2vhbl() tools = [ "> Directory Fix", #0 "> Button Test", #1 "> Pixel Fix", #2 "> Free Space", #3 "> Savedata Backup", #4 "> HBL Loader", #5 "> PSP to VHBL" #6 ] img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, tools[tools_position]) scr.blit(img) scr.swap() x = True while x == True: pad = psp2d.Controller() time.sleep(0.20) if pad.down: try: tools_position = tools_position+1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, tools[tools_position]) scr.blit(img) scr.swap() except: tools_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, tools[tools_position]) scr.blit(img) scr.swap() elif pad.up: try: tools_position = tools_position-1 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, tools[tools_position]) scr.blit(img) scr.swap() except: tools_position = 0 img.clear(CLEAR_COLOR) fnt.drawText(img, 0, 0, "Up/Down to scroll") fnt.drawText(img, 0, 30, "Cross to select") fnt.drawText(img, 0, 60, "Circle to exit") fnt.drawText(img, 0, 120, tools[tools_position]) scr.blit(img) scr.swap() elif pad.cross: x = False work() elif pad.circle: x = False done("Quit?") main()